/*
 * 
 * 
 * 
 */
package com.hboxs.asl.entity;

import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * Entity - 预存款
 */
@Entity
@Table(name = "xx_deposit")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "xx_deposit_sequence")
public class Deposit extends BaseEntity {

    private static final long serialVersionUID = -8323452873046981882L;

    public Deposit() {
    }

    public Deposit(Type type, BigDecimal credit, BigDecimal debit, BigDecimal balance, String operator, String memo, Member member, Order order, Payment payment) {
        this.type = type;
        this.credit = credit;
        this.debit = debit;
        this.balance = balance;
        this.operator = operator;
        this.memo = memo;
        this.member = member;
        this.order = order;
        this.payment = payment;
    }

    /**
     * 类型
     */
    public enum Type {

        /**
         * 会员充值
         */
        memberRecharge,

        /**
         * 会员支付
         */
        memberPayment,

        /**
         * 后台充值
         */
        adminRecharge,

        /**
         * 后台扣费
         */
        adminChargeback,

        /**
         * 后台支付
         */
        adminPayment,

        /**
         * 后台退款
         */
        adminRefunds
    }

    /**
     * 类型
     */
    private Type type;

    /**
     * 收入金额
     */
    private BigDecimal credit;

    /**
     * 支出金额
     */
    private BigDecimal debit;

    /**
     * 当前余额
     */
    private BigDecimal balance;

    /**
     * 操作员
     */
    private String operator;

    /**
     * 备注
     */
    private String memo;

    /**
     * 会员
     */
    private Member member;

    /**
     * 订单
     */
    private Order order;

    /**
     * 收款单
     */
    private Payment payment;

    /**
     * 获取类型
     *
     * @return 类型
     */
    @Column(nullable = false, updatable = false)
    public Type getType() {
        return type;
    }

    /**
     * 设置类型
     *
     * @param type 类型
     */
    public void setType(Type type) {
        this.type = type;
    }

    /**
     * 获取收入金额
     *
     * @return 收入金额
     */
    @Column(nullable = false, updatable = false, precision = 21, scale = 2)
    public BigDecimal getCredit() {
        return credit;
    }

    /**
     * 设置收入金额
     *
     * @param credit 收入金额
     */
    public void setCredit(BigDecimal credit) {
        this.credit = credit;
    }

    /**
     * 获取支出金额
     *
     * @return 支出金额
     */
    @Column(nullable = false, updatable = false, precision = 21, scale = 2)
    public BigDecimal getDebit() {
        return debit;
    }

    /**
     * 设置支出金额
     *
     * @param debit 支出金额
     */
    public void setDebit(BigDecimal debit) {
        this.debit = debit;
    }

    /**
     * 获取当前余额
     *
     * @return 当前余额
     */
    @Column(nullable = false, updatable = false, precision = 21, scale = 2)
    public BigDecimal getBalance() {
        return balance;
    }

    /**
     * 设置当前余额
     *
     * @param balance 当前余额
     */
    public void setBalance(BigDecimal balance) {
        this.balance = balance;
    }

    /**
     * 获取操作员
     *
     * @return 操作员
     */
    @Column(updatable = false)
    public String getOperator() {
        return operator;
    }

    /**
     * 设置操作员
     *
     * @param operator 操作员
     */
    public void setOperator(String operator) {
        this.operator = operator;
    }

    /**
     * 获取备注
     *
     * @return 备注
     */
    @Length(max = 200)
    @Column(updatable = false)
    public String getMemo() {
        return memo;
    }

    /**
     * 设置备注
     *
     * @param memo 备注
     */
    public void setMemo(String memo) {
        this.memo = memo;
    }

    /**
     * 获取会员
     *
     * @return 会员
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(nullable = false, updatable = false)
    public Member getMember() {
        return member;
    }

    /**
     * 设置会员
     *
     * @param member 会员
     */
    public void setMember(Member member) {
        this.member = member;
    }

    /**
     * 获取订单
     *
     * @return 订单
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "orders")
    public Order getOrder() {
        return order;
    }

    /**
     * 设置订单
     *
     * @param order 订单
     */
    public void setOrder(Order order) {
        this.order = order;
    }

    /**
     * 获取收款单
     *
     * @return 收款单
     */
    @ManyToOne(fetch = FetchType.LAZY)
    public Payment getPayment() {
        return payment;
    }

    /**
     * 设置收款单
     *
     * @param payment 收款单
     */
    public void setPayment(Payment payment) {
        this.payment = payment;
    }

}